package com.four.marketing.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.four.marketing.entity.Configure;
import com.four.marketing.dao.ConfigureDao;
import com.four.marketing.service.ConfigureService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.four.marketing.vo.ConfigureVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 侯新伟
 * @since 2021-12-14
 */
@Service
public class ConfigureServiceImpl extends ServiceImpl<ConfigureDao, Configure> implements ConfigureService {

    @Autowired
    private ConfigureDao configureDao;

    /**
     * 秒杀配置的列表查询
     * 分页 模糊 状态
     * @param vo
     * @param page
     * @param size
     * @return
     */
    @Override
    public IPage<Configure> getConfigureList(ConfigureVo vo, Integer page, Integer size) {
        Page<Configure> configurePage = new Page<>(page, size);
        return configureDao.getConfigureList(configurePage,vo);
    }

    /**
     * 添加秒杀配置
     * @param configure
     */
    @Override
    public void addConfigure(Configure configure) {
        configureDao.addConfigure(configure);
    }

    /**
     * 根据秒杀配置名查询
     * 唯一
     * @param conName
     * @return
     */
    @Override
    public Configure findConfigureBName(String conName) {
        return configureDao.findConfigureBName(conName);
    }

    /**
     * 根据id删除秒杀配置
     * @param concId
     */
    @Override
    public void delConfigureById(Integer concId) {
        configureDao.delConfigureById(concId);
    }

    /**
     * 根据id获取秒杀配置的id
     * @param conId
     * @return
     */
    @Override
    public Configure getConfigureById(Integer conId) {
        return configureDao.getConfigureById(conId);
    }

    /**
     * 修改秒杀配置
     * @param configure
     * @param conId
     */
    @Override
    public void updateConfigure(Configure configure, Integer conId) {
        configure.setConId(conId);
        configureDao.updateConfigure(configure);
    }
}
